/**
 * @file mRjson.c
 * @Synopsis  简易json解析库
 * @author Wang Jiancong
 * @version v0.2
 * @date 2022-11-22
 */

#include <stdio.h>
#include "mRjson.h"


char json[] = 	"{\"number1\":233,\"number2\":456,\"str\":\"hello world\",\"double\":3.14,\"array\":"
				"[{\"content\":\"aaaa\"},{\"content\":{\"content\":\"bbbb\",\"hello\":\"world\"}},{\"content\":\"cccc\"}]"
				",\"number3\":789}";

char ss[100] = "";

int main(void)
{
	int tmp;
	double ftmp;

	printf("*********************************************\r\n");
	printf("测试json字符串: %s\r\n\r\n",json);

	printf("整形解析测试\t\t\t\t\t: ");
	mRjson_Decode("%J%I%T%R",json,"number3","D",&tmp);
	printf("获取\"number3\" : %d\r\n", tmp);

	printf("字符串解析测试\t\t\t\t\t: ");
	mRjson_Decode("%J%I%T%R",json,"str","S",&ss[0]);
	printf("获取\"str\" \t: %s\r\n", ss);

	printf("浮点数解析测试\t\t\t\t\t: ");
	mRjson_Decode("%J%I%T%R",json,"double","F",&ftmp);
	printf("获取\"double\" \t: %f\r\n", ftmp);
	printf("\r\n");

	printf("嵌套解析测试, array[1]->content->hello \"S\"\t: ");
	mRjson_Decode("%J%I%A%G%I%T%R",json,"array","1","content","hello","S",&ss[0]);
	printf("%s\r\n", ss);

	printf("嵌套解析测试, array[2]->content \"S\"\t\t: ");
	mRjson_Decode("%J%I%A%I%T%R",json,"array","2","content","S",&ss[0]);
	printf("%s\r\n", ss);

	printf("*********************************************\r\n");
	return 0;
}







